/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.bingoogolapple.transformerstip.demo;

import cn.bingoogolapple.transformerstip.SimpleTextTip;
import cn.bingoogolapple.transformerstip.TransformersTip;
import junit.framework.TestCase;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.agp.components.Component;
import ohos.app.Context;
import org.junit.Test;

/**
 * 测试
 *
 * @author 王浩 邮件:bingoogolapple@gmail.com
 * @since 2021-05-17
 */
public class TipOhosTest extends TestCase {
    /**
     * 包名测试
     */
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("cn.bingoogolapple.transformerstip.demo", actualBundleName);
    }

    /**
     * 屏幕尺寸测试
     */
    @Test
    public void testScreenSize() {
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility().getContext();
        int ScreenWidth = Utils.getScreenSize(context).getPointXToInt();
        assertTrue(ScreenWidth > 0);
    }
    /**
     * 控件浮框测试
     */
    @Test
    public void testTransformersTip() {
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility().getContext();
        Component anchorView = new Component(context);
        Component component = new Component(context);
        TransformersTip transformersTip = new TransformersTip(anchorView, component);
        assertNotNull(transformersTip);
    }

    /**
     * 文字的浮窗测试
     */
    @Test
    public void testSimpleTextTip() {
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility().getContext();
        Component anchorView = new Component(context);
        Component component = new Component(context);
        TransformersTip simpleTextTip = new SimpleTextTip(anchorView, component);
        assertNotNull(simpleTextTip);
    }
}